<<<<<<< HEAD
<!--  -->
<template>


    <div>

        <!--            标题-->
        <el-row class=" border_bottom" type="flex" justify="start">
            <el-col :span="2">
                <h3> 签到日志</h3>
            </el-col>
        </el-row>

        <el-row>
            <el-col :span="8">
                昵称：
                <el-input style="width: 200px" v-model="petName"></el-input>
                <el-button type="primary" plain  @click="search">搜索</el-button>
                <el-button type="primary" plain  @click="refrsh">刷新</el-button>
            </el-col>

        </el-row>


        <el-row>

            <template>
                <el-table
                        ref="multipleTable"
                        :data="qiandaoList"
                        tooltip-effect="dark"
                        style="width: 100%"
                        @selection-change="handleSelectionChange">

                    <el-table-column
                            label="ID"
                            width="320">
                        <template slot-scope="scope">{{ scope.row.signId }}</template>
                    </el-table-column>
                    <el-table-column
                            label="头像"
                            width="320">

                        <template slot-scope="scope">
                            <!--                                <el-image-->
                            <!--                                        style="width: 50px; height: 50px" :src="scope.row.headimg"-->

                            <!--                                ></el-image>-->

                            <img style="width: 50px; height: 50px" :src="scope.row.headimg">
                            　　
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="user.userName"
                            label="昵称"
                            show-overflow-tooltip
                            width="320">
                    </el-table-column>

                    <el-table-column
                            prop="signPoint"
                            label="积分"
                            show-overflow-tooltip
                            width="320">
                    </el-table-column>
                    <el-table-column
                            prop="signTime"
                            label="签到日期"
                            show-overflow-tooltip
                            width="320">
                    </el-table-column>
                </el-table>
            </template>


        </el-row>
        <el-row class="fy">


            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :page-size="4"
                    layout="total, prev, pager, next"
                    :total="count">
            </el-pagination>

        </el-row>

    </div>
</template>

<script>
    import qs from 'qs'
    export default {
        name: "AnswerLog",
        data() {
            return {
                memberName: '',
                memberPhone: '',
                qiandaoList: [],
                multipleSelection: [],
                currentId: '',
                petName:'',
                count:null,
            }
        },
        methods: {
            refrsh(){
                this.$axios.post('/api/sign/list').then((res) => {
                    console.log(res);
                    this.qiandaoList = res.data.data
                    this.count=res.data.count
                    // console.log(res.data.data)
                })

            },



            //查询日志
            search() {
                console.log(this.petName);
                //发起请求
                this.$axios.post('/api/sign/list?userName='+this.petName+'&page=1').then((res) => {

                    console.log(this.petName);
                    console.log(res);


                    if (res.data.data.length>0){
                        this.qiandaoList = res.data.data

                        this.count=res.data.count
                    }else {
                        this.$message.error('没有该用户的签到信息');
                    }


                    })
            },

            toggleSelection(rows) {
                if (rows) {
                    rows.forEach(row => {
                        this.$refs.multipleTable.toggleRowSelection(row);
                    });
                } else {
                    this.$refs.multipleTable.clearSelection();
                }
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                //发送请求，查询当前页
                this.$axios.post('/api/getCurrenPage',{currentPage:val}).then((res) => {
                    this.qiandaoList = res.data
                    console.log(this.qiandaoList)
                })
                console.log(`当前页: ${val}`);
            },
            // 删除签到详细
            delAnswerLog(id) {

                this.$confirm('此操作将永久删除该信息, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    console.log('发起请求')
                    console.log(id)
                    //发起请求
                    // this.$axios.post('/api/log/deleteLog?logIds=2&logIds=3').then((res) => {
                    this.$axios.post('/api/user/delete?logIds=',[...[id]]).then((res) => {

                        console.log(id)
                        console.log(res)
                        console.log(res.data.code)
                        if (res.data.code == 200) {
                            this.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                            location.reload();
                        } else {
                            this.$message.error('删除失败');
                        }
                    //
                    })
                    console.log('请求完毕')
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });

            },




        },



        created() {
            this.$axios.post('/api/sign/list').then((res) => {
                console.log(res);
                this.qiandaoList = res.data.data
                this.count=res.data.count
                // console.log(res.data.data)
            })
        },
    }
</script>

<style scoped>
    .border_bottom {
        border-bottom: 1px solid grey;
    }

    .el-col {
        text-align: left;
    }

    .el-button {
        margin-left: 10px;
    }

    .fy {
        text-align: right;
    }
</style>